<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('reference_materials', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('type_id')->index()->default(0);
            $table->unsignedBigInteger('user_id')->index()->default(0);
            $table->unsignedBigInteger('project_id')->index()->default(0);
            $table->string('title')->nullable()->comment('名称');
            $table->string('brand')->nullable()->comment('品牌');
            $table->string('specifications')->nullable()->comment('规格型号');
            $table->string('unit')->nullable()->comment('单位');
            $table->integer('num')->default(0)->comment('数量');
            $table->decimal('price', 10, 2)->default(0)->comment('单价');
            $table->decimal('total', 10, 2)->default(0)->comment('合价');
            $table->integer('tax_rate')->default(0);
            $table->decimal('tax_price', 10, 2)->default(0)->comment('税金');
            $table->string('tax')->nullable()->comment('是否含税');
            $table->string('freight')->nullable()->comment('是否含运费');
            $table->string('installation')->nullable()->comment('是否含安装');
            $table->string('address')->nullable()->comment('工程地点');
            $table->string('material_supplier')->nullable()->comment('材料商');
            $table->string('contact')->nullable()->comment('联系人');
            $table->string('contact_mobile')->nullable()->comment('联系方式');
            $table->string('grade')->nullable()->comment('等级');
            $table->date('signing_date')->nullable()->comment('签订日期');
            $table->string('remarks')->nullable()->comment('备注');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('reference_materials');
    }
};
